// 数据源配置基础表单字段
export interface BasicField {
  id: string
  name: string
  description: string
  status: boolean
  type:string
  [key: string]: any
}

export interface HttpConnectionField {
  url: string
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'
  timeout: number
}

export interface HttpAuthorizationField {
  authType: 'none' | 'basic' | 'bearer' | 'api_key' | 'oauth2' | 'jwt' | 'hmac' | 'aws'
  
  // Basic Auth
  basicAuthLocation?: 'header' | 'query'
  basicAuthHeaderKey?: string
  basicAuthQueryKey?: string
  basicAuthUsername?: string
  basicAuthPassword?: string
  
  // Bearer Token
  bearerTokenLocation?: 'header' | 'query' | 'cookie'
  bearerTokenHeaderKey?: string
  bearerTokenQueryKey?: string
  bearerTokenCookieKey?: string
  authBearerFromRedisRead?: '0' | '1' // 0: 常量, 1: 缓存
  authBearerToken?: string
  authBearerRedisReadKey?: string
  
  // API Key
  apiKeyLocation?: 'header' | 'query'
  apiKeyHeaderKey?: string
  apiKeyQueryKey?: string
  apiKeyValue?: string
  
  // OAuth 2.0
  oauth2TokenLocation?: 'header' | 'query' | 'cookie'
  oauth2HeaderKey?: string
  oauth2QueryKey?: string
  oauth2CookieKey?: string
  oauth2ClientId?: string
  oauth2ClientSecret?: string
  
  // JWT
  jwtLocation?: 'header' | 'query' | 'cookie'
  jwtHeaderKey?: string
  jwtQueryKey?: string
  jwtCookieKey?: string
  jwtToken?: string
  
  // HMAC
  hmacKeyLocation?: 'header' | 'query'
  hmacHeaderKey?: string
  hmacQueryKey?: string
  hmacSignatureHeader?: string
  hmacSecret?: string
  
  // AWS Signature
  awsSignatureLocation?: 'header' | 'query'
  awsSignatureKey?: string
  awsAccessKey?: string
  awsSecretKey?: string
  headers?:{}
}

export interface HttpHeaderField {
	[key: string]: any
}

export interface HttpQueryParamField {
  [key: string]: any
}

export interface HttpBodyField {
  type:string
  [key: string]: any
}

export interface HttpResultField {
  succField:string,
  succFieldType:string,
  succValue:string,
  msgField:string,
  dataField:string,
  dataFieldType:string,
  dataContentModel?:Object,
  [key: string]: any
}

export	interface HttpFormData {
	basic: BasicField
	connection: HttpConnectionField,
	authorization:HttpAuthorizationField,
	headers:HttpHeaderField[],
	queryParams:HttpQueryParamField,
	body:HttpBodyField,
	result:HttpResultField
}

/**
 * MQTT 连接配置字段
 */
export interface MqttConnectionField {
  /**
   * MQTT 服务器地址
   * @example "mqtt://example.com" 或 "tcp://localhost"
   */
  host: string;
  
  /**
   * 端口号
   * @default 1883
   */
  port: number;
  
  /**
   * 连接超时时间（秒）
   * @default 30
   */
  timeout: number;
  
  /**
   * 客户端ID (可选)
   */
  clientId?: string;
  
  /**
   * 保持连接时间（秒）
   * @default 60
   */
  keepalive?: number;
  
  /**
   * 是否自动重连
   * @default true
   */
  reconnect?: boolean;
  
  /**
   * 清理会话标志
   * @default true
   */
  clean?: boolean;
  
  /**
   * 遗嘱消息主题 (可选)
   */
  willTopic?: string;
  
  /**
   * 遗嘱消息内容 (可选)
   */
  willPayload?: string;
  
  /**
   * 遗嘱消息QoS (可选)
   * @default 0
   */
  willQos?: 0 | 1 | 2;
  
  /**
   * 遗嘱消息保留标志 (可选)
   * @default false
   */
  willRetain?: boolean;
}

export interface MqttAuthorizationField {
	
	/**
	 * 是否使用SSL/TLS
	 * @default false
	 */
	ssl: boolean;
	
	/**
	 * 用户名 (可选)
	 */
	username?: string;
	
	/**
	 * 密码 (可选)
	 */
	password?: string;
	
	/**
	 * CA证书 (可选)
	 */
	ca?: string;
	
	/**
	 * 客户端证书 (可选)
	 */
	cert?: string;
	
	/**
	 * 客户端密钥 (可选)
	 */
	key?: string;
	
}

export interface MqttTopicField {
	
	/**
	 * 主题
	 */
	topic: string;
	
	/**
	 * qos
	 */
	qos:0 | 1 | 2;
	
	
}

export	interface MqttFormData {
	basic: BasicField
	connection: MqttConnectionField,
	authorization:MqttAuthorizationField,
	topics:MqttTopicField[],
}

export	interface DbConnectionField {
  dbType: string
  host: string
  port: number
  database: string
  timeout: number
  poolSize: number
  charset: string
}


export	interface DbAuthField {
  authMethod: string
  username?: string
  password?: string
  encryption: string
  sslMode?: string
  caCert?: string
  clientCert?: string
  clientKey?: string
  ldapServer?: string
  ldapDomain?: string
  connectionTimeout: number
  commandTimeout: number
  minTlsVersion: string
}

export	interface DbFormData {
	basic: BasicField
	connection: DbConnectionField,
	authorization:DbAuthField,
}



